package com.liuda066.forumssm.config;

import com.liuda066.forumssm.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/9/4 14:03
 */
@Configuration
public class AppInterceptorConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")     //拦截所有
                .excludePathPatterns("/sign-up.html") //排除登录
                .excludePathPatterns("/sign-in.html") //排除注册
                .excludePathPatterns("/user/login")//排除登录api
                .excludePathPatterns("/user/register")//排除注册api
                .excludePathPatterns("/user/logout")//排除登出api
                .excludePathPatterns("/swagger*/**")//排除swagger
                .excludePathPatterns("/v3*/**")//排除v3
                .excludePathPatterns("/dist/**")//排除静态文件
                .excludePathPatterns("/image/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/**.ico");
    }
}
